/// <reference path="fKanban.js" />
/* fKanban.UserStory */
fKanban.userStory = function () { }
fKanban.userStory.prototype = new fKanban();
fKanban.userStory.prototype.constructor = fKanban.UserStoty;
fKanban.userStory.prototype.supr = fKanban.prototype;

/* add */
fKanban.userStory.prototype.add = function (item, callback) {
    if (!item.name) item.name = "Untitled";
    if (!item.status) item.status = "to do";
    $.ajax({
        type: "POST",
        url: website + "Online/AddUserStory",
        dataType: "json",
        data: item,
        success: function (obj) {
            Info(obj.Message);
            if (callback) callback(obj.Id);
        },
        error: function (err) {
            Info(err);
        }
    });
};
/* remove */
fKanban.userStory.prototype.remove = function (id, callback) {
    $.ajax({
        type: "POST",
        url: website + "Online/RemoveUserStory",
        dataType: "json",
        data: { id: id },
        success: function (obj) {
            Info(obj.Message);
            if (callback) callback(obj.rowsAffected);
        },
        error: function (err) {
            Info(err);
        }
    });
};
/* update */
fKanban.userStory.prototype.update = function (item, callback) {
    $.ajax({
        type: "POST",
        url: website + "Online/UpdateUserStory",
        dataType: "json",
        data: item,
        success: function (obj) {
            Info(obj.Message);
            if (callback) callback(obj.rowsAffected);
        },
        error: function (err) {
            Info(err);
        }
    });
};
/* loadData */
fKanban.userStory.prototype.loadData = function (callback, onerror) {
    $.ajax({
        type: "POST",
        url: website + "Online/LoadUserStories",
        dataType: "json",
        data: { },
        success: function (obj) {
            Info(obj.Message);
            if (callback) callback(obj.Result);
        },
        error: function (err) {
            Info(err);
        }
    });
};
/* loadDataById */
fKanban.userStory.prototype.loadDataById = function (id, callback, onerror) {
    $.ajax({
        type: "POST",
        url: website + "Online/LoadUserStoryById",
        dataType: "json",
        data: { id: id },
        success: function (obj) {
            Info(obj.Message);
            if (callback) callback(obj.Result);
        },
        error: function (err) {
            Info(err);
        }
    });
};